﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Truextend.Training.Presenter.ViewInterfaces;
using Truextend.Training.Business;
using Truextend.Training.Model.Entities;
using Truextend.Training.Service;

namespace Truextend.Training.Presenter
{
    public class ListCoursePresenter
    {
        private IListCourseView view;

        public ListCoursePresenter(IListCourseView view)
        {
            if (view == null) throw new ArgumentNullException("View may not be null");
            this.view = view;
        }

        public void InitView()
        {
            try
            {
                view.Message = "Initial Message";
                //List<Course> coursesList = CourseControl.GetAllCourses();
                List<Course> coursesList = new CourseService().GetAllCourses().ToList();
                view.Courses = coursesList;
            }
            catch (Exception e)
            {
                view.Message = e.Message;
            }

        }

        public void DeleteCourse(long courseId)
        {
            //Course course = CourseControl.GetCourseById(courseId);
            //CourseControl.DeleteCourse(course);
            new CourseService().DeleteCourse(courseId);
        }
    }
}
